import 'dart:io';
import 'package:dio/dio.dart';
import 'package:dss_base/net/base_entity.dart';
import 'package:dss_base/net/http_util.dart';
import 'package:flutter_demo_test/data/bean/goods_bean.dart';

class TestRepository {
  TestRepository._();

  static final TestRepository _singleton = TestRepository._();

  factory TestRepository() => _singleton;

  static TestRepository get instance => _singleton;

  /// 上传文件
  Future<BaseEntity> getGoodsName(String goodsId) async {
    return HttpUtil.instance.get(
      url: 'api/job_app/goods_info',
      params: {"goods_id": goodsId},
    );
  }

  Future<BaseEntity> getTest(int pageIndex) async {
    await Future.delayed(Duration(seconds: 1));
    if (pageIndex >= 5) {
      return createSuccessEntity(null);
    }
    List list = [];
    for (int i = 0; i < 10; i++) {
      list.add(GoodsBean(goodsName: "page-$pageIndex-$i"));
    }
    return createSuccessEntity(list);
  }
}
